package com.example;

import com.example.service.IUserService;


import com.example.service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;



@ComponentScan(value = "com.example")
public class SpringAopDemoApplication {

    public static void main(String[] args) {
        // 设置此系统属性,让JVM生成的Proxy类写入文件.保存路径为：com/sun/proxy(如果不存在请手工创建) */
        System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", "false");

        ConfigurableApplicationContext context =  SpringApplication.run(SpringAopDemoApplication.class, args);

        //思考
        // @EnableAspectJAutoProxy(proxyTargetClass = false,exposeProxy = true)下   context.getBean(UserService.class); 报错
        // @EnableAspectJAutoProxy(proxyTargetClass = true,exposeProxy = true)下   context.getBean(UserService.class); 不报错




        IUserService userService =  context.getBean(IUserService.class);
        userService.addUser();
        System.out.println("====================");
        userService.queryUser(1);
        System.out.println("====================");
        System.out.println(userService instanceof UserService);
        System.out.println("====================");
        System.out.printf(userService.getClass().getName());
        System.out.println("====================");

    }

}
